package com.lujieni.threadpool.controller;


import com.lujieni.threadpool.service.PriceService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.concurrent.ExecutionException;

@RestController
public class PriceController {

    private PriceService priceService;

    // 构造器注入
    public PriceController(PriceService priceService){
        this.priceService = priceService;
    }

    @GetMapping("/getCheapPrice")
    public BigDecimal getCheapPrice() throws ExecutionException, InterruptedException {
        return priceService.getCheapPrice();
    }

    @GetMapping("/getCheapPriceWithCompletableFuture")
    public BigDecimal getCheapPriceWithCompletableFuture() throws ExecutionException, InterruptedException {
        return priceService.getCheapPriceWithCompletableFuture();
    }

}
